package com.youpai.platform.user.web.entity.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.youpai.platform.common.constant.BizConstant;
import com.youpai.platform.user.service.entity.po.UserPO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @author welles
 * @version 1.0
 * @description 用户DTO
 * @date 2021/7/22
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "UserFollowDTO",description = "用户详情")
public class UserFollowDTO {

    @ApiModelProperty(value = "用户id")
    private String uid;

    @ApiModelProperty(value = "用户名")
    private String userName;

    @ApiModelProperty(value = "昵称")
    private String nickName;

    @ApiModelProperty(value = "性别")
    private Integer gender;

    @ApiModelProperty(value = "头像")
    private String avatar;

    @ApiModelProperty(value = "邮箱")
    private String email;

    @ApiModelProperty(value = "生日")
    @JsonFormat(pattern = BizConstant.FORMAT_DAY, timezone = BizConstant.TIME_ZONE)
    private Date birthday;

    @ApiModelProperty(value = "手机号")
    private String mobile;

    @ApiModelProperty(value = "自我简介")
    private String summary;

    @ApiModelProperty(value = "用户accId")
    private String accId;

    public UserFollowDTO(UserPO userPO) {
        setUid(userPO.getUid().toString());
        setUserName(userPO.getUserName());
        setNickName(userPO.getNickName());
        setGender(userPO.getGender());
        setAvatar(userPO.getAvatar());
        setEmail(userPO.getEmail());
        setBirthday(userPO.getBirthday());
        setMobile(userPO.getMobile());
        setSummary(userPO.getSummary());
        if(userPO.getChatAccountPO() != null) {
            setAccId(userPO.getChatAccountPO().getAccId());
        }
    }
}
